Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Laravel dd() Output Rendering in Scribe Documentation #893

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

sabist
Copy link
Contributor

@sabist sabist commented Sep 19, 2024

This PR addresses an issue where the output of Laravel's dd() function is rendered as plain text in the generated documentation by Scribe. The changes introduce a selective rendering mechanism that safely treats dd() output as HTML while keeping all other API responses as plain text, ensuring proper security.

  • Laravel dd() detection: The script now checks for the presence of sf-dump in the response to identify dd() output.

  • Secure rendering: Only the detected dd() output is rendered using innerHTML to display the HTML dump correctly. Other responses continue to use textContent to avoid XSS vulnerabilities.

This update improves the developer experience by ensuring that Laravel debug outputs are correctly formatted in the API documentation, while maintaining security.

@shalvah
Copy link
Contributor

shalvah commented Sep 19, 2024

Good one, thanks!

@shalvah shalvah merged commit a26d9c9 into knuckleswtf:master Sep 19, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants